package com.eyeq.chat.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.eyeq.chat.model.User;
import com.eyeq.chat.service.UserManager;

/**
 * @author Administrator
 * 
 */
@Controller
// @SessionAttributes(value = { "user" }, types = { User.class })
public class SignController {

	// private Log log = LogFactory.getLog(getClass());

	@Autowired
	private UserManager ownerManager;

	@RequestMapping(value = { "/sign/signin" }, method = RequestMethod.GET)
	public String signinPageHandler(Model model) {
		return "/sign/signin";
	}

	@RequestMapping(value = { "/sign/signup" }, method = RequestMethod.GET)
	public String signupPageHandler(Model model) {
		return "/sign/signup";
	}

	@RequestMapping(value = "/sign/createUser", method = RequestMethod.POST)
	public String createUser(@ModelAttribute("User") User user) {
		ownerManager.createUser(user);

		return "redirect:/sign/signin";
	}
}
